(clipboard-yank, clipboard-kill-ring-save)
authorRichard M. Stallman <rms@gnu.org>
Wed, 6 Apr 1994 04:54:35 +0000 (04:54 +0000)
committerRichard M. Stallman <rms@gnu.org>
Wed, 6 Apr 1994 04:54:35 +0000 (04:54 +0000)
(clipboard-kill-region): New functions.  Give them
menu-enable properties and bind the PASTE, COPY and CUT keys.
(menu-bar-enable-clipboard): New function.

lisp/menu-bar.el

index ea6221ca7102aab92f9102dade0f708f80c3c6bd..8b51ba6511983fac3650c9968d439557cb704ff6 100644 (file)
 
 (autoload 'ispell-menu-map "ispell" nil t 'keymap)
 
+;; These are alternative definitions for the cut, paste and copy
+;; menu items.  Use them if your system expects these to use the clipboard
+
+(define-key global-map [cut] 'clipboard-kill-region)
+(define-key global-map [copy] 'clipboard-kill-ring-save)
+(define-key global-map [paste] 'clipboard-yank)
+
+(put 'clipboard-kill-region 'menu-enable 'mark-active)
+(put 'clipboard-kill-ring-save 'menu-enable 'mark-active)
+(put 'clipboard-yank 'menu-enable
+     '(or (x-selection-exists-p) (x-selection-exists-p 'CLIPBOARD)))
+
+(defun clipboard-yank ()
+  "Reinsert the last stretch of killed text, or the clipboard contents."
+  (interactive)
+  (let ((x-select-enable-clipboard t))
+    (yank)))
+
+(defun clipboard-kill-ring-save (beg end)
+  "Copy region to kill ring, and save in the X clipboard."
+  (interactive "r")
+  (let ((x-select-enable-clipboard t))
+    (kill-ring-save beg end)))
+
+(defun clipboard-kill-region (beg end)
+  "Kill the region, and save it in the X clipboard."
+  (interactive "r")
+  (let ((x-select-enable-clipboard t))
+    (kill-region beg end)))
+
+(defun menu-bar-enable-clipboard ()
+  "Make the menu bar CUT, PASTE and COPY items use the clipboard."
+  (interactive)
+  (define-key menu-bar-edit-menu [paste] '("Paste" . clipboard-yank))
+  (define-key menu-bar-edit-menu [copy] '("Copy" . clipboard-kill-ring-save))
+  (define-key menu-bar-edit-menu [cut] '("Cut" . clipboard-kill-region)))
+\f
 (define-key menu-bar-help-menu [emacs-tutorial]
   '("Emacs Tutorial" . help-with-tutorial))
 (define-key menu-bar-help-menu [man] '("Man..." . manual-entry))